package com.css.zfzx.sjcj.modules.hddcGeochemicalAbnSegment.repository;

import com.css.zfzx.sjcj.modules.hddcGeochemicalAbnSegment.repository.entity.HddcGeochemicalabnsegmentEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zhangcong
 * @date 2020-11-28
 */
public interface HddcGeochemicalabnsegmentRepository extends JpaRepository<HddcGeochemicalabnsegmentEntity, String> {

    @Query(nativeQuery = true, value = "select * from hddc_geochemicalabnsegment where is_valid !=0 and project_name in :projectIds")
    List<HddcGeochemicalabnsegmentEntity> queryHddcGeochemicalabnsegmentsByProjectId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_geochemicalabnsegment where is_valid = '1' ")
    List<HddcGeochemicalabnsegmentEntity> findAll();

    @Query(nativeQuery = true, value = "select * from hddc_geochemicalabnsegment where is_valid !=0 and task_name in :taskIds")
    List<HddcGeochemicalabnsegmentEntity> queryHddcGeochemicalabnsegmentsByTaskId(List<String> taskIds);

    @Query(nativeQuery = true, value = "select * from hddc_geochemicalabnsegment where create_user = :createID and province = :provinceName and city =:cityName and area =:areaName")
    List<HddcGeochemicalabnsegmentEntity> queryHddcGeochemicalabnsegmentByCreateuser(String createID,String provinceName,String cityName,String areaName);

    @Modifying
    @Query(nativeQuery = true, value = "update hddc_geochemicalabnsegment set is_valid = '0' where province = :provinceName and city =:cityName and area =:areaName and extends8 =:savefilename")
    void deleteFileData(String provinceName,String cityName,String areaName,String savefilename);
}
